package com.cheng.operation.impl;

import com.cheng.common.exception.CommonException;
import com.cheng.data.entity.TradeTypeInfEntity;
import com.cheng.operation.TradeTypeInfOperation;
import com.cheng.service.TradeTypeInfService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: ChengJW
 * @date: 2021/11/8 20:30
 * @version: 1.0
 * @description: 有关行业门类信息表 trade_type_inf 表的业务逻辑
 */
@Service
public class TradeTypeInfOperationImpl implements TradeTypeInfOperation {

    private final static Logger log = LoggerFactory.getLogger(TradeTypeInfOperationImpl.class);

    @Autowired
    private TradeTypeInfService tradeTypeInfService;

    /**
     * @author: ChengJW
     * @params: [entity]
     * @return: java.util.List<com.cheng.data.entity.TradeTypeInfEntity>
     * @date: 2021/11/8
     * @description: 查询 trade_type_inf 列表信息
     */
    @Override
    public List<TradeTypeInfEntity> queryTradeTypeInf(TradeTypeInfEntity entity) throws CommonException {
        return tradeTypeInfService.queryTradeTypeInf(entity);
    }

    /**
    * @author: ChengJW
    * @params: [code]
    * @return: java.lang.String
    * @date: 2021/11/8
    * @description: 根据行业门类代码查询 trade_type_inf 行业名称
    */
    @Override
    public String queryTradeTypeInfNmByCode(String code) throws CommonException {
        TradeTypeInfEntity entity = new TradeTypeInfEntity();
        entity.setTeTypeCode(code);
        List<TradeTypeInfEntity> list = tradeTypeInfService.queryTradeTypeInf(entity);
        String tradeTypeNm = "";
        if (null != list && list.size() > 0){
            tradeTypeNm = list.get(0).getTeTypeNm();
        }
        return tradeTypeNm;
    }
}
